package svc

import (
	"github.com/zeromicro/go-zero/core/stores/postgres"
	"go-zero-demo-04/mall/result/api/ResultModel"
	"go-zero-demo-04/mall/result/api/internal/config"
)

type ServiceContext struct {
	Config       config.Config
	ResultModel  ResultModel.TestResultsModel
	StudentModel ResultModel.StudentModel
	AnswerModel  ResultModel.AnswerModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := postgres.New(c.DB.DataSource)
	return &ServiceContext{
		Config:       c,
		ResultModel:  ResultModel.NewTestResultsModel(conn),
		StudentModel: ResultModel.NewStudentModel(conn),
		AnswerModel:  ResultModel.NewAnswerModel(conn),
	}
}
